<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="layui/css/layui.css">
<!-- <link rel="stylesheet" href="js/layui.css" media="all">
<link rel="stylesheet" href="js/admin.css" media="all"> -->
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
function checkPwd(){//登录检查密码
	var result=$("#new_logcode").val();
	var reg=/^[a-zA-Z0-9]{4,12}$/;
	if(reg.test(result)){
		$("#spcheck1").html("合法").css("color","green");
		return true;
		}else{
		$("#spcheck1").html("非法").css("color","red");
		$("#new_logcode")[0].select();
			return false;
			
			}
	};
	
function checkPayCode(){//支付密码检查密码
		var result=$("#paycode").val();
		var reg=/^[a-zA-Z0-9]{4,12}$/;
		if(reg.test(result)){
			$("#spcheck3").html("合法").css("color","green");
			return true;
			}else{
			$("#spcheck3").html("非法").css("color","red");
			$("#paycode")[0].select();
				return false;
				
				}
		};
		function checkPayReCode(){//确认支付密码
			var result=$("#paycode").val();
			var result2=$("#repaycode").val();
			if(result2==result){
				$("#spcheck4").html("两次密码输入一致").css("color","green");
				return true;
				}else{
				$("#spcheck4").html("两次密码输入不一致").css("color","red");	
				
					return false;
					
					}
		};		
		
		
		
function checkRepwd(){//确认密码
	var result=$("#new_logcode").val();
	var result2=$("#confirmation_ogcode").val();
	if(result2==result){
		$("#relogcode_prompt").html("两次密码输入一致").css("color","green");
		return true;
		}else{
		$("#relogcode_prompt").html("两次密码输入不一致").css("color","red");	
		
			return false;
			
			}
};

/*表单提交*/
function checkAll(){
  if(checkPwd() && checkRepwd())
    return true;
  else
    return false;
}

function checkAll2(){
	  if(checkPayCode() && checkPayReCode())
	    return true;
	  else
	    return false;
	}
    
    $(function(){
       	//判断输入的原始密码是否正确
    	$("#_logcode").blur(function(){
    		var logCode=$("#_logcode").val();
    		$.ajax({
    			type:'post',
    			url:'<%=basePath%>getCurrentPwdByUname.do',
    			dataType:'json',
    			data:'logCode='+logCode,
    			success:function(data){
    				if(data==1){
    					$("#updateCurPwd").html("密码正确").css("color","green");
    				}else{
    					alert("密码输入错误");
    					location.reload();
    				}
    			},
    			error:function(data){
    				alert("密码输入错误");
					location.reload();
    			}
    			
    		});
    	});
    
    	//判断输入的原始支付密码是否正确
    	$("#pwd").blur(function(){
    		var payCode=$("#pwd").val();
    		$.ajax({
    			type:'post',
    			url:'<%=basePath%>updatPayCodeByUsername.do',
    			dataType:'json',
    			data:'payCode='+payCode,
    			success:function(data){
    				if(data==1){
    					$("#pwdsss").html("密码正确").css("color","green");
    				}else{
    					alert("密码输入错误");
    					location.reload();
    				}
    			},
    			error:function(data){
    				alert("密码输入错误");
					location.reload();
    			}
    			
    		});
    	});
       	
    //修改登录密码	
    $("#qrxg").click(function(){
    	var logCode=$("#_logcode").val();
    	if(logCode!=''){
    		if(checkAll()){
        		var logCode=$("#new_logcode").val();
        		$.ajax({
        			type:'post',
        			url:'<%=basePath%>updateCurrentlogCodeByUname.do',
        			dataType:'json',
        			data: 'logCode='+logCode,
        			success:function(data){
        				if(data==1){
        					alert("密码修改成功");
        					location.reload();
        				}else{
        					alert("密码修改失败");
        					location.reload();
        				};
        			},
        			error:function(data){
        				alert("密码修改失败");
    					location.reload();
        				
        			}
        		});
        	}
    	}else{
    		alert("请输入原始密码");
    		location.reload();
    	}
    });	
    	
    	
  //修改支付密码	
    $("#qrpayCode").click(function(){
    	var payqrCode=$("#pwd").val();
    	if(payqrCode!='' ){
    		if(checkAll2()){
        		var paycode=$("#paycode").val();
        		$.ajax({
        			type:'post',
        			url:'<%=basePath%>PayCodeByUsername.do',
        			dataType:'json',
        			data: 'paycode='+paycode,
        			success:function(data){
        				if(data==1){
        					alert("密码修改成功");
        					location.reload();
        				}else{
        					alert("密码修改失败");
        					location.reload();
        				};
        			},
        			error:function(data){
        				alert("密码修改失败");
    					location.reload();
        				
        			}
        		});
        	}
    	}else{
    		alert("请输入原始密码");
    		location.reload();
    	}
    });	
    
    });
    
	
</script>
</head>
 
<body class="layui-layout-body">
<div class="layui-card-header">修改商城登录密码</div>

  
<body layadmin-themealias="default">

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
         
          <div class="layui-card-body" pad15="">
          
            
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="alogcode" id="_logcode" lay-verify="required" lay-vertype="tips" class="layui-input">
             			<span id="updateCurPwd"></span>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="blogcode" lay-verify="pass" lay-vertype="tips" autocomplete="off" id="new_logcode" onBlur="checkPwd()" class="layui-input">
                <span id="spcheck1"></span>
                </div>
                <div class="layui-form-mid layui-word-aux">4到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="clogcode" lay-verify="repass" lay-vertype="tips" autocomplete="off" id="confirmation_ogcode" onBlur="checkRepwd()" class="layui-input">
                <span id="relogcode_prompt"></span> 
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn"  id ="qrxg" onsubmit=""  lay-filter="setmypass" >确认修改</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>



	
		 <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">修改商城二级密码</div>
          <div class="layui-card-body" pad15>
          </hr>
            
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="oldPassword" id="pwd"  lay-verify="required" lay-verType="tips" class="layui-input">
                  <span id="pwdsss"></span>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="password" lay-verify="pass" onblur="checkPayCode()" lay-verType="tips" autocomplete="off"  id="paycode"  class="layui-input">
                <span id="spcheck3"></span>
                </div>
                <div class="layui-form-mid layui-word-aux">4到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="repassword" lay-verify="repass" onblur="checkPayReCode()" lay-verType="tips" autocomplete="off" id="repaycode"  class="layui-input">
                <span id="spcheck4"></span> 
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn"  id="qrpayCode" lay-filter="setmypass">确认修改</button>
                </div>
              </div>
            </div>
            
          </div>
        </div>
      </div>
    </div>
  </div>
	</form>
</div>
<style id="LAY_layadmin_theme">.layui-side-menu,.layadmin-pagetabs .layui-tab-title li:after,.layadmin-pagetabs .layui-tab-title li.layui-this:after,.layui-layer-admin .layui-layer-title,.layadmin-side-shrink .layui-side-menu .layui-nav>.layui-nav-item>.layui-nav-child{background-color:#20222A !important;}.layui-nav-tree .layui-this,.layui-nav-tree .layui-this>a,.layui-nav-tree .layui-nav-child dd.layui-this,.layui-nav-tree .layui-nav-child dd.layui-this a{background-color:#009688 !important;}.layui-layout-admin .layui-logo{background-color:#20222A !important;}</style>
 
 <!--  <script>
  layui.config({
    base: '../../../js/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set']);
  </script>
 -->
</body>
</html>